import { loginAPI } from '@/api/user'
import { delToken, setToken } from '@/utils/storage'
export default {
  state () {
    return {
      token: ''
    }
  },
  mutations: {
    changeToken (state, token) {
      state.toke = token
      setToken(token)
    },
    resetToken (state) {
      state.token = null
      delToken()
    }
  },
  actions: {
    async asyncLogin ({ commit }, ruleForm) {
      const res = await loginAPI(ruleForm)
      console.log(res);
      commit('changeToken', res.data.token)
    }
  },
  getters: {},
  namespaced: true
}